package cn.hncum.feign.clients;

import cn.hnucm.bean.TbToken;
import cn.hnucm.bean.TbUserBasicMessage;
import cn.hnucm.bean.TbUserBasis;
import cn.hnucm.bean.TbUserSign;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient("userservice")
public interface UserClient {
    @PostMapping("/userservice/tbUserSign/getUserBasisMessage/{userAccount}")
    //请求登录接口
    public List<TbUserBasicMessage> loginVerify(@PathVariable("userAccount")  String userAccount);
    //保存用户的token，如果合法用户登录退出页面后可以直接查询到token，不用再次创建token
    @PostMapping("/userservice/tbToken/addToken")
    public Boolean saveToken(@RequestBody TbToken tonken);

    //查询用户是否有token，有就直接返回，免去登录
    @GetMapping("/userservice/tbToken/getToken/{userId}")
    public List<TbToken> getUserToken(@PathVariable("userId") int id);

    //如果用户的token登录的时候过期了就更新他的token
    @PostMapping("/userservice/tbToken/updateToken")
    public Boolean updateToken(@RequestBody TbToken tonken);

    @PostMapping("/userservice/tbUserSign/addUserSign")
    public boolean addUserSign(@RequestBody TbUserSign tbUserSign);

    @GetMapping("/userservice/tbUserBasis/updateAssertById/{userId}/{userAsset}")
    public boolean updateUserBalanceById(@PathVariable("userId") int id,@PathVariable("userAsset") float balance);

    @GetMapping("/userservice/tbUserBasis/getUserBasis/{userId}")
    public List<TbUserBasis> getUserBasisById(@RequestHeader(name = "userId") String userId, @RequestHeader(name = "userIp") String userIp, @PathVariable("userId") int id);
}
